package edu.java.lectures.lec08.exceptions.basics;

import java.util.Scanner;

public class TryCatchFinallyConstruct1 {

    public static void main(String[] args) {
	System.out.println("Enter a number: ");
	Scanner input = new Scanner(System.in);
	int number = input.nextInt();
	if (input != null) {
	    input.close();
	    input = null;
	}
	try { // try to minimize the size of the try-block
	    int a = 5 / number;
	    Object obj = null;
	    obj.toString();
	    System.out.println("Pesho"); // must NOT be here
	} catch (ArithmeticException ae) {
	    System.out.println("in the arithmetic catch block");
	    // process the exceptional event
	} catch (NullPointerException npe) {
	    System.out.println("in the null-pointer catch block");
	} finally { // not compulsory
	    System.out.println("in the finally block");
	}
	System.out.println("Out of try-catch-block.");
    }
}
